
#include <world.h>
#include <camera.h>

#include <stdlib.h>

vm_vector cam_loc;
vm_vector cam_or;
unsigned int x, y;
int i;
vm_camera *cam;
vm_world *world;
vm_vector vects[3];
vm_vector r_vects[3];

void load_vects();
void render();
void stress_render();

int main(){

  x = 600;
  y = 400;
  
  ZERO(cam_loc);
  cam_or.x = 1;
  cam_or.y = 1;
  cam_or.z = 1;
  cam_or.w = 0;

  cam = vm_make_camera();
  vm_set_cam_loc(cam, cam_loc);
  vm_set_cam_look(cam, cam_or);
  vm_set_cam_size(cam, x, y);

  world = vm_make_empty_world();
  vm_pregenerate(world, cam);
  vm_print_world_data(world);

  load_vects();

  render();

}

void load_vects(){

  FILE *f = fopen("../data/transform.vec", "r");
  for ( i = 0; i < 3; i++){
    int ok = vm_read(f, &(vects[i]));
    if (!ok) {
      printf("Error reading vectors.\n");
      exit(1);
    }
  }
  fclose(f);

}


void render(){

  for ( i = 0; i < 3; i++){
    vm_render(world, vects[i], &(r_vects[i]));
    printf("Rendered vector: ");
    vm_println(r_vects[i]);
  }

}

void stress_render(){

  
  
}
